package edu.jd.movieplatform.info.cinema;


import edu.jd.movieplatform.common.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/info/cinema")
public class CinemaAPI {

    @Resource
    private CinemaService cinemaService;


    @RequestMapping("/cinema-list")
    public Result cinemaList(CinemaDto dto){

        List<Cinema> cinemaList = cinemaService.getCinemaList(dto);
        return Result.success(cinemaList);

    }

    @RequestMapping("/cinema-list-name")
    public Result cinemanameList(){

        List<Cinema> cinemaList = cinemaService.getCinemaNameList();
        List<String> cinemanameList = new ArrayList<>();
        for(int i=0;i<cinemaList.size();i++){
            cinemanameList.add(cinemaList.get(i).getCnm_name());
        }

        return Result.success(cinemanameList);

    }

    @RequestMapping("/cinema-list-byid")
    public Result cinemaListById(Integer cnm_id){
        CinemaDto dto = new CinemaDto();
        dto.setCnm_id(cnm_id);

        List<Cinema> cinemaList = cinemaService.getCinemaList(dto);
        return Result.success(cinemaList);

    }

}
